<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <input type="button" name="" id="btn1" value="btnbtn"/><br/>
  <input type="text" name="" /><br/>
  <input type="text" name="" /><br/>
  <input type="text" name="" /><br/>
  <input type="text" name="" /><br/>
  <input type="text" name="" /><br/>
  <script>
    var btn = document.getElementById('btn1');
    var list = document.getElementsByTagName('input');
    var arr = []; // 方法1 使用数组，推荐
    var str = ''; // 方法2 直接使用字符串拼接
    btn.onclick = function () {
      for (let i = 0; i < list.length; i++) {
        if (list[i].type === 'text') {
          arr.push(list[i].value);
        }
      }
      for (let i = 0; i < list.length -1; i++) {
        if (list[i].type === 'text') {
          str += list[i].value + '|';
        }
      }
      console.log(str + list[list.length - 1].value);
      // console.log(arr.join('|'));
    }
  </script>
</body>
</html>